Two raster graphic elements, both of which have color and opacity (also known as “alpha” and “transparency”) defined at each point of the elements may be combined. These two elements may be combined through a method of compositing for example as described by Porter and Duff in the publication entitled “Compositing Digital Images”; Computer Graphics, Vol. 18 No. 3 (1984) pp. 253-259 (hereafter Porter and Duff). In particular, in this method, an upper (or source) graphic element (s) and a lower (or destination) graphic element (d) may be composited together with an over operator (one of several operators defined in the publication). The composition of the graphic elements produces a resultant graphic clement (r) in accordance with the following Equations (1) and (2) applied at each point (e.g., a pixel):ro=do*(1−so)+so  (1)rc=(dc*do*(1−so)+sc*so)/ro  (2)where:    ro represents a result opacity (a value ranging from 0 . . . 1 representing the degree of opacity, with 0 being completely transparent and 1 being completely opaque);    do represents opacity of the lower graphic element;    so represents opacity of the upper graphic element;    rc represents a result color. There may be several color channels in a graphic element, such as red, green, and blue for a color image. The rc calculation is used for each such channel;    dc represents the color of a lower graphic element; and    sc represents the color of an upper graphic element.
To simplify the compositing equations (and operations) for simple compositing it is sometimes convenient to use pre-multiplied color values. A pre-multiplied color value is the color value multiplied by the corresponding opacity value. For example, in pre-multiplied form, the Porter and Duff over operation becomes:ro=do*(1−so)+so  (3)rco=dco*(1−so)+sco  (4)where:    rco represents rc*ro;    dco represents dc*do; and    sco represents sc*so.
However, pre-multiplied forms of the Porter and Duff compositing operations are only usefull to a sub-set of compositing operations. In the remainder of this description, operations will be described in terms of un-premultiplied values unless otherwise stated.
A second known method of combining two graphic elements is based upon combining the colors of pairs of opaque graphic elements. Examples of such color combining operations include bit-wise logical raster operations (“raster ops”) as exercised by Microsoft Windows Graphical Device Interface (GDI) Application Programming Interface (API) with operations such as R2_MERGEPEN (bitwise OR), and R2_MASKPEN (bitwise AND). Such color combining operations also include “transfer modes” as exercised by Adobe Photoshop with functions such as LIGHTEN, and DARKEN. The above operations, which are just examples of a large class of functions, are defined in Table 1 as follows:
TABLE 1 OperationEquationR2_MERGEPENrc = sc | dcR2_MASKPENrc = sc & dcLIGHTENrc = MAX(sc, dc)DARKENrc = MIN(sc, dc)
Many such operations are possible and exercised by various graphic systems. However, the above definitions assume both s and d are completely opaque elements. A generalization of color combining operations where a graphic element with non-unity opacity (referred to herein as a semi-transparent element) is being combined with a transfer function onto (i.e., over) an opaque background element is exercised in Adobe PhotoShop and described in U.S. Pat. No. 6,421,460 (Hamburg). Hamburg discloses the following compositing equation:ro=1  (5)rc=T(sc, dc)*so+dc*(1−so)  (6)where T is the transfer function (such as LIGHTEN or DARKEN) producing a transfer color.
Note however that in the above case the lower graphic element (d) is assumed to be fully opaque.
U.S. Pat. No. 6,483,519 by Long et. al. (also U.S. patent application Ser. No. 10/176,644 filed Nov. 24, 2002, by Long et. al.) describes a method of combining two graphical objects (an upper graphic element and a lower graphic element) with a transfer function, both objects having a non-unity opacity value. U.S. Pat. No. 6,421,460 by Hamburg, describes a less generic method for combining an upper graphic element and a lower graphic element. The method of combining two graphic elements described above uses the equations:ro=do*(1−so)+so*do+so*(1−do)  (7)rc=(dc*do*(1−so)+T(sc, dc)*so*do+sc*so*(1−do))/ro  (8)These equations can be derived by extending the ideas of Porter and Duff. They allow the combination of semi-transparent graphic elements with raster operations such as R2_MERGEPEN or transfer functions such as LIGHTEN. Such color combining operations had previously been considered incompatible with partial opacity of the lower graphic element.
Whilst Long et. al. (U.S. Pat. No. 6,483,519) describes a graphics accelerator capable of efficiently performing the above generalized technique, for systems without such an accelerator there are a number of practical difficulties in using the above technique. Firstly, the compositing equations are computationally expensive and must be performed on every pixel pair of the two operands of an operation. Such computation is a heavy burden when carried out in a software system. Compounding this problem is the common use of graphics acceleration based on application specific integrated circuits. Graphics accelerators are now commonly used in desktop computers and printers to achieve an acceptable level of graphics performance. However, such accelerators have only a limited repertoire of primitive operations. These primitive operations may include both Porter and Duff compositing, and/or raster operations (or transfer functions), however they do not usually allow the general case of Porter and Duff compositing in the presence of raster operations (or transfer functions) where both operands can have transparency, as described above. This can present considerable difficulties since there are large time penalties for stopping the pipeline of a graphics accelerator in order to substitute software calculations for aspects that the graphics accelerator is unable to compute. When combined with the very expensive calculations described above, the performance penalty is large.
Thus, a need clearly exists for a more efficient method of combining a first graphic element and a second graphic element, where this combining may be performed by accelerators that have a limited repertoire of primitive operations as described above.